#! /bin/bash

err_exit()
{
	echo "err: $@"
	exit 1
}

pts=$(readlink /proc/$$/fd/0) || err_exit "query pts fail"
pts=${pts#/dev/}
echo pts=$pts

[ -z "$pts" -o -n "${pts##pts/*}" ] && err_exit "Only support pts."

info=$(who | grep "$pts")
echo info=$info
ip=${info##* (}
ip=${ip%)}
echo ip=$ip

echo Do mount from $ip
opts="ip=$ip,username=yanyg,password=asdfghjkl;',uid=yanyg,gid=yanyg"
for x in /media/{win-data,win-os};do
	[ -d "$x" ] || sudo mkdir -p $x
done

sudo mount -t cifs -o$opts //$ip/c /media/win-os
sudo mount -t cifs -o$opts //$ip/e /media/win-data
